//axios二次封装
import axios from 'axios'
import store from '../store'
//创建axios实例
let instance = axios.create({
    baseURL:'/api',
    timeout:10000
})

//拦截器
//请求拦截器
instance.interceptors.request.use((config)=>{
    if(store.state.userMessage.token){
        config.headers.token = store.state.userMessage.token
    }
    return config
})
//响应拦截器
instance.interceptors.response.use((res)=>{
    return res.data
},(err)=>{
    return Promise.reject(err)
})
export default instance